package com.ruiyian.web.controller.system;

import com.ruiyian.common.annotation.Log;
import com.ruiyian.common.core.controller.BaseController;
import com.ruiyian.common.core.domain.AjaxResult;
import com.ruiyian.common.core.page.TableDataInfo;
import com.ruiyian.common.enums.BusinessType;
import com.ruiyian.common.utils.poi.ExcelUtil;
import com.ruiyian.system.domain.GsdMapInfo;
import com.ruiyian.system.service.IGsdMapInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 路线路段Controller
 *
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/map")
public class GsdMapInfoController extends BaseController
{
    @Autowired
    private IGsdMapInfoService gsdMapInfoService;

    /**
     * 查询路线路段列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GsdMapInfo gsdMapInfo)
    {
        startPage();
        List<GsdMapInfo> list = gsdMapInfoService.selectGsdMapInfoList(gsdMapInfo);
        return getDataTable(list);
    }

    /**
     * 导出路线路段列表
     */
    @Log(title = "路线路段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GsdMapInfo gsdMapInfo)
    {
        List<GsdMapInfo> list = gsdMapInfoService.selectGsdMapInfoList(gsdMapInfo);
    }

    /**
     * 获取路线路段详细信息
     */
    @GetMapping(value = "/{roadId}")
    public AjaxResult getInfo(@PathVariable("roadId") Long roadId)
    {
        return success(gsdMapInfoService.selectGsdMapInfoByRoadId(roadId));
    }

    /**
     * 新增路线路段
     */
    @Log(title = "路线路段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GsdMapInfo gsdMapInfo)
    {
        return toAjax(gsdMapInfoService.insertGsdMapInfo(gsdMapInfo));
    }

    /**
     * 修改路线路段
     */
    @Log(title = "路线路段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GsdMapInfo gsdMapInfo)
    {
        return toAjax(gsdMapInfoService.updateGsdMapInfo(gsdMapInfo));
    }

    /**
     * 删除路线路段
     */
    @Log(title = "路线路段", businessType = BusinessType.DELETE)
    @DeleteMapping("/{roadIds}")
    public AjaxResult remove(@PathVariable Long[] roadIds)
    {
        return toAjax(gsdMapInfoService.deleteGsdMapInfoByRoadIds(roadIds));
    }
}
